🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / ble / src / commonMain / kotlin / org / meshtastic / core / ble / BleExceptionClassifier.kt
Displaying Raw • Download
core/ble/src/commonMain/kotlin/org/meshtastic/core/ble/BleExceptionClassifier.kt cca7c274b98dbe224c3df6f511da7f3263c697ab (cca7c274) Text, 2.90 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tf0883e@fileTb4b4b4:Te6edf3SuppressTb4b4b4(Ta5d6ff"Ta5d6ffMatchingDeclarationNameTa5d6ff"Tb4b4b4) T8b949e// File groups the classifier function and its result type.
Tff7b72package T7ee787org.meshtastic.core.ble
Tff7b72import T7ee787com.juul.kable.GattRequestRejectedException
Tff7b72import T7ee787com.juul.kable.GattStatusException
Tff7b72import T7ee787com.juul.kable.NotConnectedException
Tff7b72import T7ee787com.juul.kable.UnmetRequirementException
T8b949e/**
* Classification of a BLE-layer exception for the transport layer to act on.
*
* @property isPermanent `true` if the condition cannot resolve without explicit user re-selection of the device.
* Currently always `false` — all known BLE exceptions can resolve without user intervention (BT toggling, permission
* grants, transient GATT errors). Reserved for future use.
* @property gattStatus the platform GATT status code when available (Android-specific).
* @property message a human-readable description of the failure.
*/
Tff7b72data Tff7b72class T56d364BleExceptionInfoTb4b4b4(Tff7b72val Te6edf3isPermanentTb4b4b4: Tffa657BooleanTb4b4b4, Tff7b72val Te6edf3gattStatusTb4b4b4: Tffa657Int? Tff7b72= Tff7b72nullTb4b4b4, Tff7b72val Te6edf3messageTb4b4b4: Tffa657StringTb4b4b4)
T8b949e/**
* Inspects this [Throwable] and returns a [BleExceptionInfo] if it is a known Kable exception, or `null` if it is
* unrelated to the BLE layer.
*
* This keeps Kable type knowledge inside `core:ble` so that `core:network` (and other consumers) can classify BLE
* exceptions without depending on Kable directly.
*/
Tff7b72fun Te6edf3ThrowableTb4b4b4.Td2a8ffclassifyBleExceptionTb4b4b4(Tb4b4b4)Tb4b4b4: Te6edf3BleExceptionInfo? Tff7b72= Tff7b72when Tb4b4b4(Tff7b72thisTb4b4b4) Tb4b4b4{
Tff7b72is Te6edf3GattStatusException Tff7b72-Tff7b72>
Te6edf3BleExceptionInfoTb4b4b4(
Te6edf3isPermanent Tff7b72= Tff7b72falseTb4b4b4,
Te6edf3gattStatus Tff7b72= Te6edf3statusTb4b4b4,
Te6edf3message Tff7b72= Ta5d6ff"Ta5d6ffGATT error (status Tffd700$Te6edf3statusTa5d6ff): Tffd700$Te6edf3messageTa5d6ff"Tb4b4b4,
Tb4b4b4)
Tff7b72is Te6edf3NotConnectedException Tff7b72-Tff7b72> Te6edf3BleExceptionInfoTb4b4b4(Te6edf3isPermanent Tff7b72= Tff7b72falseTb4b4b4, Te6edf3message Tff7b72= Ta5d6ff"Ta5d6ffNot connectedTa5d6ff"Tb4b4b4)
Tff7b72is Te6edf3GattRequestRejectedException Tff7b72-Tff7b72>
Te6edf3BleExceptionInfoTb4b4b4(Te6edf3isPermanent Tff7b72= Tff7b72falseTb4b4b4, Te6edf3message Tff7b72= Ta5d6ff"Ta5d6ffGATT request rejected (busy)Ta5d6ff"Tb4b4b4)
Tff7b72is Te6edf3UnmetRequirementException Tff7b72-Tff7b72>
T8b949e// Bluetooth disabled or runtime permission missing. Both can resolve without re-selecting the
T8b949e// device (user re-enables BT, or grants permission). Surface as transient so the transport keeps
T8b949e// retrying; UI can show a hint based on the message.
Te6edf3BleExceptionInfoTb4b4b4(Te6edf3isPermanent Tff7b72= Tff7b72falseTb4b4b4, Te6edf3message Tff7b72= Te6edf3message Tff7b72?: Ta5d6ff"Ta5d6ffBluetooth LE unavailableTa5d6ff"Tb4b4b4)
Tff7b72else Tff7b72-Tff7b72> Tff7b72null
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.11s